<?php
/**
 * JoiGallery - image gallery component for Joostina
 *
 * Добавление/редактирование категории
 *
 * @version 1.0 alpha 12
 * @package JoiGallery
 * @subpackage	AdminView
 * @filename edit_category_.php
 * @author JoostinaTeam
 * @copyright (C) 2008-2009 Joostina Team
 * @license see license.txt
 *
 **/
 
defined('_VALID_MOS') or die();

//Загружаем jQuery
mosCommonHTML::loadJquery();
//Загружаем FancyBox
mosCommonHTML::loadJqueryPlugins('fancybox/jquery.fancybox',false, true);
//Загружаем библиотеку всплывающих подсказок
mosCommonHTML::loadOverlib();

?>

<script language="javascript" type="text/javascript">

  function submitbutton(pressbutton) {
      var form = document.adminForm;
      if (pressbutton == 'cancel') {
              submitform( pressbutton );
              return;
      }
      if (pressbutton == 'save') {
              if (form.name.value == "") {
                alert('<?php echo _C_JOIGALLERY_MSG_CATEGORY_NO_NAME; ?>');
                $("form").submit(function () { return false; });
              }
              else if (form.title.value == "") {
                alert('<?php echo _C_JOIGALLERY_MSG_CATEGORY_NO_TITLE; ?>');
                $("form").submit(function () { return false; });
              }
              else {
                <?php getEditorContents( 'editor1', 'description' ) ; ?>
                submitform(pressbutton);
              }
      }

  }

  function ch_apply(){
    var form = document.adminForm;
    if (form.name.value == "") {
      alert('<?php echo _C_JOIGALLERY_MSG_CATEGORY_NO_NAME; ?>');
      $("form").submit(function () { return false; });
    }
	else $(".change_name").text(form.name.value);
	
    if (form.title.value == "") {
      alert('<?php echo _C_JOIGALLERY_MSG_CATEGORY_NO_TITLE; ?>');
      $("form").submit(function () { return false; });
    }
    else {
      SRAX.get('tb-apply').className='tb-load';
      <?php getEditorContents('editor1','description'); ?>
              dax({
                    url: 'ajax.index.php?option=com_joigallery&act=categories&task=apply',
                    id:'publ-1',
                    method:'post',
                    form: 'adminForm',
                    callback:
                            function(resp){
                            log('Получен ответ: ' + resp.responseText);
                            mess_cool(resp.responseText);
                            SRAX.get('tb-apply').className='tb-apply';
                    }});
              }
    }
</script>

<table class="adminheading">
  <tr>
    <th class="categories">
     <?php echo _C_JOIGALLERY_COMPONENT;
           echo $row->id ? _C_JOIGALLERY_CATEGORY_EDIT.'&nbsp;::&nbsp;<span class="change_name">'.$row->name.'</span>' 
		                 : _C_JOIGALLERY_CATEGORY_ADD;
      ?>
    </th>
  </tr>
</table>

<form action="index2.php" method="post" name="adminForm" id="adminForm">
  <?php $tabs = new mosTabs(1,1); ?>
  <?php $tabs->startPane("joigallery_category"); ?>
  <?php $tabs->startTab(_C_JOIGALLERY_COMMON, "joigallery_cat-0"); ?>

  <table class="adminform">
    <tr>
     <td colspan="3">&nbsp;</td>
    </tr>
        
    <tr>
      <td class="pl20"><?php echo _C_JOIGALLERY_CATEGORY_NAME ?></td>
      <td colspan="2"><input class="text_area" type="text" name="name" value="<?php echo stripslashes( $row->name ); ?>" size="50" maxlength="255" title="<?php echo _C_JOIGALLERY_CATEGORY_NAME_TIP ?>" /></td>
    </tr>
    <tr>
      <td class="pl20" width="150"><?php echo _C_JOIGALLERY_ALIAS ?></td>
      <td colspan="2"><input class="text_area" type="text" name="title" value="<?php echo stripslashes( $row->title ); ?>" size="50" maxlength="50" title="<?php echo _C_JOIGALLERY_CATEGORY_TITLE_TIP ?>" /></td>
    </tr>
    <tr>
     <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td class="pl20"><?php echo _C_JOIGALLERY_CATEGORY_PARENT ?></td>
      <td><?php echo $lists['parent_id']; ?></td>
    </tr>
    <tr>
     <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td class="pl20"><?php echo _C_JOIGALLERY_PUBLISHED ?></td>
      <td><?php echo $lists['published']; ?></td>
    </tr>
    <tr>
     <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td class="pl20" valign="top"><?php echo _C_JOIGALLERY_DESCRIPTION ?></td>
      <td>
      <?php
      // parameters : areaname, content, hidden field, width, height, rows, cols
      editorArea( 'editor1',  $row->description , 'description', '100%;', '300', '60', '20' ) ;
      ?>
      </td>
    </tr>    
    <tr>
     <td colspan="3">&nbsp;</td>
    </tr>
  </table>

  <?php $tabs->endTab(); ?>
  <?php $tabs->startTab(_C_JOIGALLERY_META, "joigallery_cat-1"); ?>

  <table class="adminform">
    <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr>
      <td class="pl20 title"><?php echo _C_JOIGALLERY_TITLE ?> <?php echo mosToolTip(_C_JOIGALLERY_CONF_META_TITLE_TIP); ?></td>
      <td><textarea class="txta1" rows="2" cols="80" name="meta_title"><?php echo $meta[0] ?></textarea></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="pl20 title"><?php echo _C_JOIGALLERY_DESCRIPTION ?> <?php echo mosToolTip(_C_JOIGALLERY_CONF_META_DESC_TIP); ?></td>
      <td><textarea class="txta1" rows="2" cols="80" name="meta_desc"><?php echo $meta[1] ?></textarea></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="pl20 title"><?php echo _C_JOIGALLERY_KW ?> <?php echo mosToolTip(_C_JOIGALLERY_CONF_META_KW_TIP); ?></td>
      <td><textarea  class="txta1" rows="2" cols="80" name="meta_kw"><?php echo $meta[2] ?></textarea></td>
      <td align="left">
        <a class="iframe" href="http://wordstat.yandex.ru/advq?rpt=ppc&key=&shw=1&tm=&checkboxes=&text=">
          <img src="<?php JPATH_SITE ?>/images/M_images/yandex.png" 
               alt="Яндекс" border="0"
               title="<?php echo _C_JOIGALLERY_CONF_META_KW_STAT ?>" />
        </a>
      </td>
    </tr>
    <tr>
      <td colspan="3">&nbsp;</td>
    </tr>
  </table>

  <?php $tabs->endTab(); ?>
  <?php $tabs->endPane(); ?>

  <input type="hidden" name="option" value="<?php echo $option; ?>" />
  <input type="hidden" name="act" value="categories" />
  <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="hidemainmenu" value="0" />

</form>

<script type="text/javascript">

 $("a.iframe").fancybox({
   //"hideOnContentClick" : true,
   "frameWidth"  : 900,	 // ширина окна, px (425px - по умолчанию)
   "frameHeight" : 450 // высота окна, px(355px - по умолчанию)
 });
 //$.fancybox.showActivity();

</script>